org.jboss.byteman.agent
Class RuleScript

java.lang.Object
  extended by org.jboss.byteman.agent.RuleScript

public class RuleScript
extends java.lang.Object

details of a single rule obtained from a rule file. RuleScritp instances are stored in the script repository attached to the transformer. They are used to generate Rule instances at transform time. The RuleScript contains a list of Transforms which detail failed or successful transforms performed using the script.


Constructor Summary
RuleScript(java.lang.String name, java.lang.String targetClass, boolean isInterface, boolean isOverride, java.lang.String targetMethod, java.lang.String targetHelper, Location targetLocation, java.lang.String ruleText, int line, java.lang.String file)
          standard constructor for a rule
 
Method Summary
 java.lang.String getFile()
           
 int getLine()
           
 java.lang.String getName()
           
 java.lang.String getRuleText()
           
 java.lang.String getTargetClass()
           
 java.lang.String getTargetHelper()
           
 Location getTargetLocation()
           
 java.lang.String getTargetMethod()
           
 java.util.List<Transform> getTransformed()
          getter for list of transforms applied for this script.
 int getTransformedCount()
          return a count of the number of transforms applied for this script.
 boolean hasTransform(java.lang.Class<?> clazz)
          check whether a rule has been used to transform a specific class.
 boolean isDeleted()
          called when indexing a script to ensure that it has not already been deleted.
 boolean isInterface()
           
 boolean isOverride()
           
 void purge()
          uninstall any rules associated with this script.
 void recordCompile(java.lang.String triggerClass, java.lang.ClassLoader loader, boolean successful, java.lang.String detail)
          record the fact that a rule has been compiled with or without success
 boolean recordFailedTransform(java.lang.ClassLoader loader, java.lang.String internalClassName, java.lang.Throwable th)
          record the fact that an error was thrown when attempting to transform a given class using this rule script
 boolean recordMethodTransform(java.lang.ClassLoader loader, java.lang.String internalClassName, java.lang.String triggerMethodName, java.lang.String desc, Rule rule)
          record the fact that a trigger call has been successfully installed into bytecode associated with a specific class and loader and a corresponding rule instance been installed
 boolean recordTransform(java.lang.ClassLoader loader, java.lang.String internalClassName, java.lang.String triggerMethodName, java.lang.String desc, Rule rule, java.lang.Throwable th)
          record the fact that a trigger call has failed to install into bytecode associated with a specific class and loader
 boolean setDeleted()
          invoked by the scriptmanager when a rule is redefined to inhibit further transformations via this script
 java.lang.String toString()
           
 void writeTo(java.io.PrintWriter writer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RuleScript

public RuleScript(java.lang.String name,
                  java.lang.String targetClass,
                  boolean isInterface,
                  boolean isOverride,
                  java.lang.String targetMethod,
                  java.lang.String targetHelper,
                  Location targetLocation,
                  java.lang.String ruleText,
                  int line,
                  java.lang.String file)
standard constructor for a rule

Parameters:
name -
targetClass -
isInterface -
isOverride -
targetMethod -
targetHelper -
targetLocation -
ruleText -
line -
file -
Method Detail

getName

public java.lang.String getName()

getTargetClass

public java.lang.String getTargetClass()

isInterface

public boolean isInterface()

getTargetHelper

public java.lang.String getTargetHelper()

getTargetMethod

public java.lang.String getTargetMethod()

isOverride

public boolean isOverride()

getTargetLocation

public Location getTargetLocation()

getRuleText

public java.lang.String getRuleText()

getLine

public int getLine()

getFile

public java.lang.String getFile()

getTransformed

public java.util.List<Transform> getTransformed()
getter for list of transforms applied for this script. must be called synchronized on the script.

Returns:
the list of transforms

getTransformedCount

public int getTransformedCount()
return a count of the number of transforms applied for this script. must be called synchronized on the script.

Returns:
the size of the list of transforms

setDeleted

public boolean setDeleted()
invoked by the scriptmanager when a rule is redefined to inhibit further transformations via this script

Returns:
the previous setting of deleted

isDeleted

public boolean isDeleted()
called when indexing a script to ensure that it has not already been deleted. it must only be called when synchronized on the script. This avoids a race where a script can be added by thread A, deleted by thread B, unindexed -- unsuccessfully -- by thread B then indexed by thread A

Returns:
the previous setting of deleted

recordFailedTransform

public boolean recordFailedTransform(java.lang.ClassLoader loader,
                                     java.lang.String internalClassName,
                                     java.lang.Throwable th)
record the fact that an error was thrown when attempting to transform a given class using this rule script

Parameters:
loader -
internalClassName -
Returns:

recordMethodTransform

public boolean recordMethodTransform(java.lang.ClassLoader loader,
                                     java.lang.String internalClassName,
                                     java.lang.String triggerMethodName,
                                     java.lang.String desc,
                                     Rule rule)
record the fact that a trigger call has been successfully installed into bytecode associated with a specific class and loader and a corresponding rule instance been installed

Parameters:
loader -
internalClassName -
Returns:

recordTransform

public boolean recordTransform(java.lang.ClassLoader loader,
                               java.lang.String internalClassName,
                               java.lang.String triggerMethodName,
                               java.lang.String desc,
                               Rule rule,
                               java.lang.Throwable th)
record the fact that a trigger call has failed to install into bytecode associated with a specific class and loader

Parameters:
loader - the loader of the class being transformed
internalClassName - the internal name of the class being transformed
th - throwable generated during the attempt to parse the rule text or inject code at the trigger point
Returns:

hasTransform

public boolean hasTransform(java.lang.Class<?> clazz)
check whether a rule has been used to transform a specific class. this can be used when rules are redefined to decide whether or not a class needs to be retransformed. Note that it must only be called after the script has been deleted by calling setDeleted.

Parameters:
clazz - the class for which a transform is being sought.
Returns:
true if the class has been transformed using this script otherwise false.

recordCompile

public void recordCompile(java.lang.String triggerClass,
                          java.lang.ClassLoader loader,
                          boolean successful,
                          java.lang.String detail)
record the fact that a rule has been compiled with or without success

Parameters:
triggerClass - the name of the trigger class to which the rule is attached
loader - the classloader of the trigger class
successful - true if the rule compiled successfully and false if it suffered from parse, type or compile errors

purge

public void purge()
uninstall any rules associated with this script. this is called after marking the script as deleted and regenerating the methods for any associated transformed class to ensure that it does not cause a rule trigger call to fail.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

writeTo

public void writeTo(java.io.PrintWriter writer)


Copyright © 2011. All Rights Reserved.